package com.kuangstudy.collection.set;

import com.kuangstudy.oop.demo3.Person;

import java.util.Objects;

/**
 * ClassName: Student
 * date: 2021/07/12 20:15:42
 *
 * @author zlk
 */
public class Student{
    private String name;
    private Integer age;

    public Student(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(name, student.name) && Objects.equals(age, student.age);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

//    /*先按姓名比，再按照年龄来比*/
//    @Override
//    public int compareTo(Student o) {
//        int n1 = this.name.compareTo(o.getName());
//        int n2 = this.age - o.age;
//        return n1 == 0?n2:n1;
//    }
}
